﻿using System;
using Caliburn.Micro;
using DomusDotNet.Sbm.Client.WP7.Services;

namespace DomusDotNet.Sbm.Client.WP7.Framework
{
    public class CommandResult : IResult
    {
        readonly ICommand command;
        public IBackend Backend { get; set; }

        public CommandResult(ICommand command)
        {
            this.command = command;
        }

        public void Execute(ActionExecutionContext context)
        {
            Backend.Send(command);
            Completed(this, new ResultCompletionEventArgs());
        }

        public event EventHandler<ResultCompletionEventArgs> Completed = delegate { };
    }
}